package com.jiutong.meipenggang.ui.activitys;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jiutong.meipenggang.R;
import com.jiutong.meipenggang.adapters.MyInvestAdapter;
import com.jiutong.meipenggang.base.BaseActivity;
import com.jiutong.meipenggang.common.Constants;
import com.jiutong.meipenggang.entity.MainPageBean;
import com.jiutong.meipenggang.entity.MyInverstBean;
import com.jiutong.meipenggang.http.model.interfaces.MainPageBiz;
import com.jiutong.meipenggang.http.present.MainPagePresent;
import com.jiutong.meipenggang.utils.SpConfig;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MyInverstActivity extends BaseActivity implements MainPageBiz {

    @Bind(R.id.rl_common_title_back)
    RelativeLayout rlCommonTitleBack;
    @Bind(R.id.tv_common_title)
    TextView tvCommonTitle;
    @Bind(R.id.commom_question)
    ImageView commomQuestion;
    @Bind(R.id.inverst_right_now)
    TextView inverstRightNow;
    @Bind(R.id.rc_my_inverst)
    RecyclerView rcMyInverst;
    @Bind(R.id.activity_my_inverst)
    LinearLayout activityMyInverst;
    private MainPagePresent mainPagePresent;
    private List<MyInverstBean.ListBean> inverstList;

    @Override
    public int getLayoutResouceId() {
        return R.layout.activity_my_inverst;
    }

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        tvCommonTitle.setText("我的投资");
    }

    @Override
    protected void initDate(Bundle savedInstanceState) {
        mainPagePresent = new MainPagePresent(this, this);
        mainPagePresent.MyInverst();


    }

    @OnClick({R.id.rl_common_title_back, R.id.tv_common_title, R.id.commom_question, R.id.inverst_right_now, R.id.rc_my_inverst, R.id.activity_my_inverst})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_common_title_back:
                finish();
                break;
            case R.id.tv_common_title:
                break;
            case R.id.commom_question:
//                openActivity();
                break;
            case R.id.inverst_right_now:
                break;
            case R.id.rc_my_inverst:
                break;
            case R.id.activity_my_inverst:
                break;
        }
    }

    @Override
    public String getPersonalId() {
        return null;
    }

    @Override
    public String getToken() {
        return null;
    }

    @Override
    public void onMainPageSuccess(MainPageBean subjects) {

    }

    @Override
    public void onSuccess(Object object) {
        MyInverstBean myInverstBean = (MyInverstBean) object;
        SpConfig.getInstance().edit().putString(Constants.TOKEN, myInverstBean.getToken()).commit();
        inverstList = myInverstBean.getList();
        MyInvestAdapter myInvestAdapter = new MyInvestAdapter(this, R.layout.item_my_inverst, inverstList);
        rcMyInverst.setLayoutManager(new LinearLayoutManager(this));
        rcMyInverst.setAdapter(myInvestAdapter);
    }

    @Override
    public void onError(Throwable e) {

    }

    @Override
    public int getOpt() {
        return 0;
    }
}
